function [H]=affinetrans(points1,points2)
points1=[points1,ones(size(points1,1),1)];
points2=[points2,ones(size(points2,1),1)];
pts1=points1(:,1);
pts2=points1(:,2);
H1=points2'*points2\points2'*pts1;
H2=points2'*points2\points2'*pts2;
H=[H1';H2';[0 0 1]];
end